package com.chii.colorization.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.PagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.bumptech.glide.Glide;
import com.chii.colorization.R;
import com.chii.colorization.ui.adapter.PhotoAdapter;
import com.chii.colorization.utils.GlideEngine;
import com.github.chrisbanes.photoview.OnPhotoTapListener;
import com.github.chrisbanes.photoview.PhotoView;
import com.luck.picture.lib.PictureSelector;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class PhotoActivity extends AppCompatActivity {
    @BindView(R.id.view_pager)
    ViewPager viewPager;
    @BindView(R.id.view_pager_num)
    TextView viewPagerNum;
    private ArrayList<String> urls;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_photo);
        ButterKnife.bind(this);
        initData();
        initPager();

    }

    private void initData() {
        Intent intent = getIntent();
        urls = intent.getStringArrayListExtra("urls");
    }

    private void initPager() {
        PagerAdapter pagerAdapter = new PhotoAdapter(this, urls);
        viewPager.setAdapter(pagerAdapter);
        viewPagerNum.setText(1+"/"+urls.size());
        viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
                viewPagerNum.setText(position+1+"/"+urls.size());
            }
        });

    }
}
